$OpenBSD: patch-Source_cmake_OptionsCommon_cmake,v 1.11 2017/05/10 10:57:54 ajacoutot Exp $

Our ar(1) is too old and have not support for `T'.

Undefined references to libc functions.

Index: Source/cmake/OptionsCommon.cmake
--- Source/cmake/OptionsCommon.cmake.orig
+++ Source/cmake/OptionsCommon.cmake
@@ -27,10 +27,10 @@ option(USE_THIN_ARCHIVES "Produce all static libraries
 if (USE_THIN_ARCHIVES)
     execute_process(COMMAND ${CMAKE_AR} -V OUTPUT_VARIABLE AR_VERSION)
     if ("${AR_VERSION}" MATCHES "^GNU ar")
-        set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>")
-        set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>")
-        set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> rT <TARGET> <LINK_FLAGS> <OBJECTS>")
-        set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> rT <TARGET> <LINK_FLAGS> <OBJECTS>")
+        set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+        set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+        set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
+        set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
     endif ()
 endif ()
 
@@ -183,9 +183,9 @@ if (NOT MSVC)
     string(REGEX MATCHALL "-fsanitize=[^ ]*" ENABLED_COMPILER_SANITIZERS ${CMAKE_CXX_FLAGS})
 endif ()
 
-if (UNIX AND NOT APPLE AND NOT ENABLED_COMPILER_SANITIZERS)
-    set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
-endif ()
+#if (UNIX AND NOT APPLE AND NOT ENABLED_COMPILER_SANITIZERS)
+#    set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
+#endif ()
 
 if (USE_ARM_LLVM_DISASSEMBLER)
     find_package(LLVM REQUIRED)
@@ -224,13 +224,13 @@ if (NOT APPLE)
 endif ()
 
 # Macros for determining HAVE values.
-include(CheckIncludeFile)
+include(CheckIncludeFiles)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
 
 macro(_HAVE_CHECK_INCLUDE _variable _header)
-    check_include_file(${_header} ${_variable}_value)
+    check_include_files("${_header}" ${_variable}_value)
     SET_AND_EXPOSE_TO_BUILD(${_variable} ${_variable}_value)
 endmacro()
 
@@ -257,7 +257,7 @@ _HAVE_CHECK_INCLUDE(HAVE_FEATURES_H features.h)
 _HAVE_CHECK_INCLUDE(HAVE_ERRNO_H errno.h)
 _HAVE_CHECK_INCLUDE(HAVE_LANGINFO_H langinfo.h)
 _HAVE_CHECK_INCLUDE(HAVE_MMAP sys/mman.h)
-_HAVE_CHECK_INCLUDE(HAVE_PTHREAD_NP_H pthread_np.h)
+_HAVE_CHECK_INCLUDE(HAVE_PTHREAD_NP_H "pthread.h;pthread_np.h")
 _HAVE_CHECK_INCLUDE(HAVE_STRINGS_H strings.h)
 _HAVE_CHECK_INCLUDE(HAVE_SYS_PARAM_H sys/param.h)
 _HAVE_CHECK_INCLUDE(HAVE_SYS_TIME_H sys/time.h)
